package com.ym.core.config;

import com.ym.core.filter.ChannelFilter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;

/**
 * Filter配置
 *
 * @author bird
 */
@Configuration
public class FilterConfig {
	
	@Bean
	public FilterRegistrationBean channelFilter() {
		String includeUri = "/*";
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setDispatcherTypes(DispatcherType.REQUEST);
		registration.setFilter(new ChannelFilter());
		registration.addUrlPatterns(StringUtils.split(includeUri, ","));
		registration.setName("channelFilter");
		registration.setOrder(1);
		return registration;
	}
}
